<?php
/*
 * Created on 13.01.2006
 *
 */
 
 
class c_includeHandler 
{
    
    function startElement (& $sender, $attrs)
    {
        if (!$attrs['page'])
        {
            die ("Attribute page are missing at include tag\n");
        }
        $code = 'array_pop($viewparts); 
                $page = explode("/", '.$attrs['page'].');
                while ($page[0] == \'..\')
                {
                    array_shift($page);
                    array_pop($viewparts);
                }
                $view = join("/", $viewparts)."/".join("/", $page);
                $viewparts = explode(\'/\', $view);
                if (file_exists($this->basedir . \'view/\'. $view)) 
                {
                    if (file_exists($this->basedir . \'view/\'. $view.\'.inc.php\'))
                    {
                        $cfile = stat($this->basedir . \'view/\'. $view.\'.inc.php\');
                        $sfile = stat($this->basedir . \'view/\'. $view);
                        // mtime comparison
                        if ($cfile[9] < $sfile[9])
                            $this->compilePSP($this->basedir . \'view/\'. $view, 
                                $this->basedir . \'view/\'. $view.\'.inc.php\');
                    }
                    else
                    {
                        $this->compilePSP($this->basedir . \'view/\'. $view, 
                            $this->basedir . \'view/\'. $view.\'.inc.php\');
                    }
                    include($this->basedir . \'view/\'.$view.\'.inc.php\');
                }
                else
                    print ("<b>PSP File not found!</b></br>");'."\n";
        $sender->appendCode($code);
    }
    
    function endElement (& $sender)
    {
    }

}

?>
